#include <stdio.h>
#include <stdlib.h>
 
#include "duck.h"
 
Duck newDuck (int posX, int posY, char* kind) 
{
   Duck duck;
 
   duck = (Duck) malloc(sizeof(Duck_struct));
  
   duck->pos_x = posX;
   duck->pos_y = posY;
   duck->kind = kind;
   duck->quack = quack;

   printf("%s duck with position (%d,%d) has been discovered!\n", duck->kind, duck->pos_x, duck->pos_y);
   
   return duck;
}

void destroy(Duck this) {
   printf("Duck has been died.\n");
   if (this != NULL) free(this);
}

static void quack(Duck this) {
   Duck thisDuck = (Duck) this;
   printf("%s duck: quack-quack\n", thisDuck->kind);
}